package example.lesson08_01;

public class TestAbstract {

    public static void main(String[] args) {
        Shape shape=new Circle(1);
        shape.printArea();
        shape=new Rectangle(2,3);
        shape.printArea();
    }
}

    abstract class  Shape{
        public abstract void printArea();


    }

    class Circle extends Shape{
        double radius;

        public Circle(double radius) {
            this.radius = radius;
        }
        @Override
        public void printArea(){
            System.out.println("area:"+Math.PI*radius*radius);
        }

    }

    class Rectangle extends Shape {
        double width;
        double height;

        //Alt+Insert快捷键
        public Rectangle(double width, double height) {
            this.width = width;
            this.height = height;
        }

        public void printArea() {
            System.out.println("area:" + width * height);
        }
      }


